package com.xiaoq.distribution.service.impl;

import com.xiaoq.distribution.entity.SettleHistoryEntity;
import com.xiaoq.distribution.repository.ISettleHistoryRepository;
import com.xiaoq.distribution.service.ISettleHistoryService;
import com.xiaoq.vo.PagingVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by chenjh on 2018/7/11.
 */
@Service
public class SettleHistoryServiceImpl implements ISettleHistoryService {

    @Autowired
    private ISettleHistoryRepository settleHistoryRepository;

    @Override
    public void save(SettleHistoryEntity settleHistoryEntity) {
        settleHistoryRepository.save(settleHistoryEntity);
    }

    @Override
    public List<SettleHistoryEntity> getSettleHistoryList(String shopId, String distributorId, Integer theLatestSettle) {
        return settleHistoryRepository.getSettleHistoryList(shopId, distributorId, theLatestSettle ,null, null, null);
    }

    @Override
    public SettleHistoryEntity getByDistributorId(String distributorId, Integer theLatestSettle) {
        return settleHistoryRepository.getByDistributorId(distributorId, theLatestSettle);
    }

    @Override
    public boolean updateById(SettleHistoryEntity settleHistoryEntity) {
        return settleHistoryRepository.updateById(settleHistoryEntity);
    }

    @Override
    public List<SettleHistoryEntity> getSettleHistoryListWithDistriIdList(String shopId, List<String> distributorIdList, Integer theLatestSettle) {
        return settleHistoryRepository.getSettleHistoryListWithDistriIdList(shopId, distributorIdList, theLatestSettle);
    }

    @Override
    public SettleHistoryEntity getById(String id) {
        if(StringUtils.isNotBlank(id)){
            return settleHistoryRepository.getById(id);
        }
        return null;
    }

    @Override
    public List<SettleHistoryEntity> getSettleHistoryList(String shopId, String distributorId, Integer theLatestSettle, Long settleBeginTime, Long settleEndTime, PagingVo pagingVo) {
        return settleHistoryRepository.getSettleHistoryList(shopId, distributorId, theLatestSettle, settleBeginTime, settleEndTime, pagingVo);
    }

    @Override
    public long getSettleHistoryCount(String shopId, String distributorId, Integer theLatestSettle, Long settleBeginTime, Long settleEndTime, PagingVo pagingVo) {
        return settleHistoryRepository.getSettleHistoryCount(shopId, distributorId, theLatestSettle, settleBeginTime, settleEndTime, pagingVo);
    }
}
